 <script th:inline="javascript">
/*<![CDATA[*/
	
   function loadCategory(val){
			if(val == 5){
				document.getElementById("div").style.display="";
			}else{
				document.getElementById("div").style.display="none";	
			}
			
   }

    function del(event,element,data){
    	event.preventDefault();
      	bootbox.confirm("您确定删除吗?", function(result) {
    	if(result){
    		var _id = $(element).attr("href").split("_")[0];
    		var _page=$(element).attr("href").split("_")[1];
    		var _viewState = $(element).attr("href").split('_')[2];
    		BOSS.remoteCall('goods/goods/delete',$('#div_goods_grid'),{id:_id,page:_page,viewState:_viewState});
    		}
    	}); 
    }
    
    function updateStatus(event,element,data){
    	event.preventDefault();
      	//bootbox.confirm("您确定操作上下架吗?", function(result) {
    	//if(result){
    		var update = "update";
    		var _id = $(element).attr("href").split("_")[0];
    		var _page=$(element).attr("href").split("_")[1];
    		var _viewState = $(element).attr("href").split('_')[2];
    		BOSS.remoteCall('goods/goods/updateState',$('#div_goods_grid'),{id:_id,page:_page,viewState:_viewState,update:update});
    	//	}
    	//}); 
    }

    function selectAll(str)
    	{
    		if($(str).is(":checked")){
    	    		$("input[name='checkname']").attr("checked",true);
    	    		$(".checker>span").addClass("checked");
    	       }else{	
    	    		$("input[name='checkname']").attr("checked",false);
    	    		$(".checker>span").removeClass("checked");
    	     	}
    	}
    	  
	function checkValue(event,element){
		event.preventDefault();
		var _id = "1";
		var obj = document.getElementById("sel");
		var str=document.getElementsByName("checkname");
		var objarray=str.length;
		var _chestr="";
		for (i=0;i<objarray;i++)
		{
		  if(str[i].checked == true)
		  {
			  _chestr+=str[i].value+",";
		  }
		}
		if(_chestr.length == 0){
			alert("您未选中商品");
		}
		if(obj.value == 2 && _chestr!=""){
			
	      	bootbox.confirm("您确定删除吗?", function(result) {
	        	if(result){
	        		var _page=$(element).attr("href").split("_")[0];
	        		var _viewState = $(element).attr("href").split('_')[1];
	        		BOSS.remoteCall('goods/goods/delete',$('#div_goods_grid'),{id:_id,page:_page,viewState:_viewState,chestr:_chestr});
	        		}
	        	}); 
			
    		
		}else if(obj.value == 3  && _chestr!=""){
			bootbox.confirm("您确定上架吗?", function(result) {
	        	if(result){
	        		var update = "update";
	        		var _status ="up";
	        		var _page=$(element).attr("href").split("_")[0];
	        		var _viewState = $(element).attr("href").split('_')[1];
	        		BOSS.remoteCall('goods/goods/updateState',$('#div_goods_grid'),{id:_id,page:_page,viewState:_viewState,status:_status,chestr:_chestr,update:update});
	        		}
	        	}); 
			
		}else if(obj.value == 4 && _chestr!=""){
			bootbox.confirm("您确定下架吗?", function(result) {
	        	if(result){
	        		var update = "update";
	        		var _status ="down";
	        		var _page=$(element).attr("href").split("_")[0];
	        		var _viewState = $(element).attr("href").split('_')[1];
	        		BOSS.remoteCall('goods/goods/updateState',$('#div_goods_grid'),{id:_id,page:_page,viewState:_viewState,status:_status,chestr:_chestr,update:update});
	        		}
	        	}); 
		}

    }

/*]]>*/
</script>
<table layout:fragment="goods_table" class="table table-striped table-bordered  table-advance table-hover" id="goods_grid">
	<thead>
		<tr>
			<th>
				<input type="checkbox" onclick="selectAll(this)"/>
			</th>
			<th>编号</th>
			<th>商品名称</th>
			<th>货号</th>
			<th>价格</th>
			<th>是否上架</th>
			<th>排序</th>
			<th>上传人</th>
			<th>更新时间</th>
			<th>创建时间</th>
			<th>库存</th>
			<th>操作</th>
		</tr>
	</thead>	
	<tbody>
		<tr class="odd gradeX" th:each="data : ${goodsPage}">
		
			<td >

			 <input type="checkbox" name="checkname" th:attr="value=${data.id}" /> 
				
			</td>
			
			<td th:text="${data.id}"> 
				
			</td>
			
			
			<td th:text="${data.name}" width="300px">
				 hstyle
			</td>

			
			<td th:text="${data.goodsSN}">
			
			</td>
			<td th:text="${data.shopPrice}">
				 
			</td>
			<td class="center"   >
			
			<span >
                    <span th:if="${data.displayed == false}">
                            <a th:href="${data.id}+'_'+${goodsPage.number}+'_'+${viewState}" th:attr="id=${'link_delete_'+dataStat.index},name=${'link_delete_'+dataStat.index}" onclick="updateStatus(event,this);" style="color:#ff0000"	class="fa fa-times" >
                            </a>
                    </span>
                    <span th:if="${data.displayed == true}">
                            <a th:href="${data.id}+'_'+${goodsPage.number}+'_'+${viewState}" th:attr="id=${'link_delete_'+dataStat.index},name=${'link_delete_'+dataStat.index}" onclick="updateStatus(event,this);" class="fa fa-check"			
							></a>
                    </span>
                </span>
				 
			</td>
			
			<td th:text="${data.goodsManageSort}">
				 
			</td>
			
			<td th:text="${data.uploadPerson}">
				 
			</td>
			
			<td th:text="${data.modifiedDate.toLocalDate()}">
				 
			</td>
			
			<td th:text="${data.createdDate.toLocalDate()}">
				 
			</td>
			<td th:text="${data.goodsStore}">
				 
			</td>
			<td>
                 <a href="" th:href="@{'/goods/goods/match/'+${data.id}+'?page='+${goodsPage.number}+'&amp;viewState='+${viewState}}"  class="btn default btn-xs purple" th:attr="id=${'link_match_'+dataStat.index},name=${'link_match_'+dataStat.index}" ><i class="fa fa-edit"></i>搭配管理|</a>
                 <a href="" th:href="@{'/goods/goods/edit/'+${data.id}}"  class="btn default btn-xs purple" th:attr="id=${'link_edit_'+dataStat.index},name=${'link_edit_'+dataStat.index}" ><i class="fa fa-edit"></i>编辑</a>|
				 <a href="#" th:href="${data.id}+'_'+${goodsPage.number}+'_'+${viewState}" th:attr="id=${'link_delete_'+dataStat.index},name=${'link_delete_'+dataStat.index}" class="btn default btn-xs purple" onclick="del(event,this);"><i class="fa fa-minus"></i>回收站</a>|
				 <a href="#" th:href="@{'/goods/album/index/'+${data.id}}" th:attr="id=${'link_delete_'+dataStat.index},name=${'link_delete_'+dataStat.index}" class="btn default btn-xs purple" ><i class="fa fa-minus"></i>相册</a>
			</td>		 
		</tr>
		
		<tr >
			<td colspan="12" align="center" th:if="${goodsPage.getNumberOfElements() == 0}" >未查到任何记录，请放大查询条件试试</td>
		</tr>
		
 	</tbody>
 	
	
</table>
<table>
<select id='sel' onchange="loadCategory(this.value)"> 
  <option value ="1">请选择..</option>  
  <option value ="2">回收站</option>  
  <option value ="3">上架</option>  
  <option value="4">下架</option>  
</select>

<button href="#" th:href="${goodsPage.number}+'_'+${viewState}" onclick="checkValue(event,this);">
<a >
确定
</a>
</button> 
</table>


<div th:include="page_footer" th:with="viewState=${viewState},url=${'/goods/goods/index'},pageContext=${goodsPage}"></div>
